export default {
  props: {
    // 文字说明
    label: {
      type: String,
      default: () => ''
    },

    // 提示语
    placeholder: {
      type: String,
      default: () => ('')
    },

    // 当前表单类型
    form_type: {
      type: String,
      default: () => ''
    },

    // 原生类型number ,text....
    pattern: String,

    // 唯一标识
    id: String,

    // 类型
    d_type: {
      type: String,
      default: () => 'text'
    },

    // 是否操作
    can_do: {
      type: Boolean,
      default: () => false
    },

    // 表单关联项
    ref_child: {
      type: Array,
      default: () => []
    },

    // 错误信息展示
    isErrorMessage: {
      type: Boolean,
      default: () => true
    },

    titleProps: {
      type: Object,
      default: () => ({
        show: true
      })
    }
  },

  computed: {
    // 操作
    canDo() {
      return this.can_do || this.disabled;
    },

    // 当前表单
    refCustomForm() {
      const { customForm } = this.$refs;
      return customForm;
    },

    // form 实例
    vanFormGenerator() {
      return this?.$$parent?.$refs?.vanFormGenerator || undefined;
    },

    // table 实例
    vanFormTable() {
      return this?.$$table;
    },

    // collectInfo
    collectInfo() {
      return null;
    },

    // 表单className
    fieldClassName() {
      return {
        field: true,
        can_do_field: this.canDo,
        validate_error_field: this.isValidate
      };
    }
  },

  inject: ['$$parent', '$$table', '$customTable'],

  methods: {
    getElements() {
      return this;
    },

    validate() {
      return new Promise((resolve, reject) => {
        resolve(true);
      });
    }
  }
};
